#! /bin/sh

set -e

echo "Checking for .orig files"

DOT_ORIG_WHITELIST=$(cat <<EOF
/bin/hostname.orig
/etc/resolv.conf.orig
/lib/systemd/system/alsa-utils.service.orig
/sbin/start-stop-daemon.orig
EOF
)

DOT_ORIG_FILES=$(find / -type f -name *.orig | grep -v -F "$DOT_ORIG_WHITELIST" || :)

if [ -n "$DOT_ORIG_FILES" ]; then
    echo "Some patches are fuzzy and leave .orig files around:" >&2
    echo "$DOT_ORIG_FILES" >&2
    exit 1
fi
